/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package factory;


import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.state.StateBasedGame;

/**
 *
 * @author wida46984148
 */
public class MoveShoot extends Shoot{

    Image image;

    public MoveShoot(double dany, Image image) {
        super(dany);
        this.image = image;

    }
/**
     * Canvia la posicio del projectil
     * @param posX
     * @param posY
     */
    @Override
    public void setLocation(float posX, float posY) {
        super.setLocation(posX, posY);
        super.shape = new Rectangle(posX, posY, image.getWidth(), image.getHeight());
    }


    /**
     * Rederitza el projectil
     * @param gc
     * @param g
     */
    @Override
    public void render(GameContainer gc, Graphics g) {
        g.drawImage(image, posX, posY);
    }

    /**
     * Copia el projectil
     * @return projectil clonat
     */
    @Override
    public Shoot copiarShoot() {
        return new MoveShoot(dany, image);
    }

    /**
     * Getter projectil clonat
     * @return projectil
     */
    public Shoot cloneShoot() {
        Shoot p = (Shoot) copiarShoot();
        p.setLocation(posX, posY);
        return p;
    }

    /**
     * Genera impacte
     */
    public void impacte() {
        this.destroy = true;
    }

    @Override
    public void update(GameContainer gc, StateBasedGame sb, int delta) {
        if (posX > 1024) {
            destroy = true;
        } else {
            posX += 0.2 * delta;
            shape.setLocation(posX, posY);
        }
    }

    public Image getImage() {
        return image;
    }

    @Override
    public void update(int delta){
        if (posY <= -10){
            posY = -11;
            posX = 1000;
            destroy = true;
        } else {
            posY -= 10;
            shape.setLocation(posX, posY);
        }
    }

}
